package SetExample;

import java.util.Dictionary;
import java.util.Hashtable;
import java.util.List;
import java.util.TreeMap;

public class TreeMapExample {
    public static void main(String[] args) {
        TreeMap<Key,String> treeMap=new TreeMap<>();
        treeMap.put(new Key(),"value 1");
        treeMap.put(new Key(),"value 2");
        System.out.println(treeMap.toString());

        Dictionary<String,String> dictionary=new Hashtable<>();
        dictionary.put("a","A");

    }
}

class Key implements Comparable<Key>{

    //这个比较方法，就为TreeMap提供了比较方法，由它来确定放入的是不是同一个对象。
    @Override
    public int compareTo(Key o) {
        return -1;
    }
}
